from day01.basecla import BaseClass
from day01.basecla import driver
from selenium.webdriver.common.by import By
from time import sleep
c=BaseClass()
c.open_browser('http://sahitest.com/demo/promptTest.htm')
myclick=c.location(By.XPATH,'//input[@name="b1"]')
mytext=c.location(By.XPATH,"//input[@name='t1']")
myclick.click()
myclick1=driver.switch_to.alert
print('弹出提示消息为：',myclick1.text)
data1='学习Python测试自动化'
myclick1.send_keys(data1)
myclick1.accept()
data2=mytext.get_attribute('value')
if data1==data2:
    print('功能正确')
else:
    print('功能错误')
sleep(2)
myclick.click()
myclick2=driver.switch_to.alert
data1='34'
myclick2.send_keys(data1)
myclick2.dismiss()
data2=mytext.get_attribute('value')
if data1!=data2:
    print('点击的是取消按钮！')
sleep(2)
c.close_browser()